JFIF $ d d 7 * Z qn )ZP 0 !1 A "#a$2Qr D8 a Ri [f \m I ykI w0 c u F c Rı?lO7 к _f˓ [C $殷WF< _W ԣ s Kc ëI zyQy /_LK ℂ ;C",p F A : /] =H ~ , l s / 9 ć: [=/#f ; ) x { ٛE Q )~ = 𘙲r*2~ a _V = ' ku m F D } KYYC )( { * g& f `툪 r y ` = ^ c J. I ]( * `wq 1dđ #̩ ͑ 0 ; H ] u 搂 @:~ ו K L N s h } O I R* 8 :2 ! lD JV o ( 3 = M ( z Ȱ+i *N A r6K n S l ) ! J J Ӂ* % ݉?|D } d5: eP0 R; {$X' x F @ .ÊB {,WJ uQ ɲRI ;9 Q E琯 6 2fT .DU J ;*c P A\IL Nj! J ۱+ O\ ͔ ] ޒ S J ȧ c%A N ol ՎprU L Zԛe r E2= X D Xg VQeӓ k y P7 U* o m Q I s ,K `) 6\G3t?pgjr m ۛجw luGt f h 9uyP 0D;Uڽ"OXl i f $ ) &|ML 0 Z rm1 [ H XP l P R0 'G=i 2N +0 e 2 ]] 9 VT P O 7 h(F * 癈 ' = Q VZD F,d ߬ ~ T X G[ `le 69C R(!S2! P < 0 x < !1AQ "Raq 02Br #S CTb ? Ζ "]mH5WR 7 k.ۛ ! } Q~ + yԏ z |@ T20 S~ K e k *zF f^2X *( @ 8 r ? C I uI|֓>^Ex LgNU Y+{.R Ѫ τV YT D I 6 2 '8Y2 7'\T P.6 d &˦ @V q i |8 -O Ε ] ʔ U= T L 8= ;6c | !qfF3 a ů& ~$ l} 'NW U s$U k^S V : U#6w + +s &r+n ڐ { @ 29gL u " T Ù M=6 (^ "7 r}=6Yݾ lC u hquymp Ǧ G jhs ǜNl ɻ} o 7 #S6 a w 4 ! OS r D 5 7 % | ?x> L | / nD 6?/8 w # [ ) L 7 +6〼T A T g ! %5 Mm Z /c -{1_Je "| ^$ 'O & ޱմ < H vNqϡQ$ < 6 &Nݛ ֨tǻN (9 n ru~'όN sMG& ,uH Kw *Ī 5@ u6 BԒ i YN * f 0 _ GhKW u lT <nj- 0{ M L~ | /a v\ E = ?1 \ɟuq Ђ Y O a K ޡP q $ H8o Q˼EV ~ k 0 h' L Pp M -M" m^ !6l nմ 쮝C U T . ! :vMǨb h ډ Vc r @~p # !1QAa q ? AL0L x LU 4 d ; x " 16ad0 7.\ߋ 0 = P l v/ " c A Ay A|2pO8"d MV #1] = \ " ˡ ] k v I9 d ۓ & q ) ǐq E ꞅ v "P )q X &Q З non]я u ג./ ; gZ$ M QР 2M ]h ni 0 P $ێ 3CɏGjώy : m c # S_ l@ '_ \m|C 2`K _ 1 cIvGc $? PCQ S+D ? K aײ k Fr b 8 ύ NEدg ĝ U 3 6 #Ik+ v { v i ( ވ ? a e) X xy/*@Q Ǽ Ծ ) $ IWO l c G; !i k{ gOŀ L ('x T rb $ w) R $ & N1E td U3Uȉ1p M"N* (DNy d96.(jQ) X 5 c QɎMy W ? Q *!R > 6=7)Xj 5`J ] e 8%t ! + ' ! 1Q 5 !1 AQaq ё #2 "0BRb ? G t^ ## .l lQ T $ v , ,m 㵜5u bV =sY+ @d { N ! dn O < .- B; _w J t 6;Q Jd. Q c%p{ 1 ,sND dF H I0 Гo X ш e黅X ۢ F :)[ F G X ƹ / w _c MeD ,ʡc c . W D tA $ j@ : ) - #u c1< @ۗ9F ) KJ- hpP] _ x [ q B lb p ʖ w q " LFGd ƶ * s +ډ_Zc " ? % t[I P 6 J ]# =ɺ V v v CGs Gh1 > )6 |e y ? L ӣ m,4 G W Ui ` ] uJVo VDG< SB 6ϏQ @ TiU l y O U 0 kfV ~ ~}S Z @ *WU Ui ## ; s /[ = ! 7}" W N ] ' (L ! ~ y5 g9T̅J kbM' +s :S +B) v @ M j e C f j E 0 Y\Qn z G 1 д~ W o{T 9?` Rm yhsy3 !HAD ] m c1 ~ 2 L S u7x T ;j$ `} 4-> L# vzŏ I L S ֭ T { r jGK C ; b pU= - ` Bs K. S F w4 M q] Z dH S 0 ) tLg
<?php
/**
* File with the class to handle data from wpSEO.de.
*
* @package WPSEO\Admin\Import\Plugins
*/
/**
* Class WPSEO_Import_WPSEO.
*
* Class with functionality to import & clean wpSEO.de post metadata.
*/
class WPSEO_Import_WPSEO extends WPSEO_Plugin_Importer {
/**
* The plugin name.
*
* @var string
*/
protected $plugin_name = 'wpSEO.de';
/**
* Meta key, used in SQL LIKE clause for delete query.
*
* @var string
*/
protected $meta_key = '_wpseo_edit_%';
/**
* Array of meta keys to detect and import.
*
* @var array
*/
protected $clone_keys = [
[
'old_key' => '_wpseo_edit_description',
'new_key' => 'metadesc',
],
[
'old_key' => '_wpseo_edit_title',
'new_key' => 'title',
],
[
'old_key' => '_wpseo_edit_canonical',
'new_key' => 'canonical',
],
[
'old_key' => '_wpseo_edit_og_title',
'new_key' => 'opengraph-title',
],
[
'old_key' => '_wpseo_edit_og_description',
'new_key' => 'opengraph-description',
],
[
'old_key' => '_wpseo_edit_og_image',
'new_key' => 'opengraph-image',
],
[
'old_key' => '_wpseo_edit_twittercard_title',
'new_key' => 'twitter-title',
],
[
'old_key' => '_wpseo_edit_twittercard_description',
'new_key' => 'twitter-description',
],
[
'old_key' => '_wpseo_edit_twittercard_image',
'new_key' => 'twitter-image',
],
];
/**
* The values 1 - 6 are the configured values from wpSEO. This array will map the values of wpSEO to our values.
*
* There are some double array like 1-6 and 3-4. The reason is they only set the index value. The follow value is
* the default we use in the cases there isn't a follow value present.
*
* @var array
*/
private $robot_values = [
// In wpSEO: index, follow.
1 => [
'index' => 2,
'follow' => 0,
],
// In wpSEO: index, nofollow.
2 => [
'index' => 2,
'follow' => 1,
],
// In wpSEO: noindex.
3 => [
'index' => 1,
'follow' => 0,
],
// In wpSEO: noindex, follow.
4 => [
'index' => 1,
'follow' => 0,
],
// In wpSEO: noindex, nofollow.
5 => [
'index' => 1,
'follow' => 1,
],
// In wpSEO: index.
6 => [
'index' => 2,
'follow' => 0,
],
];
/**
* Imports wpSEO settings.
*
* @return bool Import success status.
*/
protected function import() {
$status = parent::import();
if ( $status ) {
$this->import_post_robots();
$this->import_taxonomy_metas();
}
return $status;
}
/**
* Removes wpseo.de post meta's.
*
* @return bool Cleanup status.
*/
protected function cleanup() {
$this->cleanup_term_meta();
$result = $this->cleanup_post_meta();
return $result;
}
/**
* Detects whether there is post meta data to import.
*
* @return bool Boolean indicating whether there is something to import.
*/
protected function detect() {
if ( parent::detect() ) {
return true;
}
global $wpdb;
$count = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->options} WHERE option_name LIKE 'wpseo_category_%'" );
if ( $count !== '0' ) {
return true;
}
return false;
}
/**
* Imports the robot values from WPSEO plugin. These have to be converted to the Yoast format.
*
* @return void
*/
private function import_post_robots() {
$query_posts = new WP_Query( 'post_type=any&meta_key=_wpseo_edit_robots&order=ASC&fields=ids&nopaging=true' );
if ( ! empty( $query_posts->posts ) ) {
foreach ( array_values( $query_posts->posts ) as $post_id ) {
$this->import_post_robot( $post_id );
}
}
}
/**
* Gets the wpSEO robot value and map this to Yoast SEO values.
*
* @param int $post_id The post id of the current post.
*
* @return void
*/
private function import_post_robot( $post_id ) {
$wpseo_robots = get_post_meta( $post_id, '_wpseo_edit_robots', true );
$robot_value = $this->get_robot_value( $wpseo_robots );
// Saving the new meta values for Yoast SEO.
$this->maybe_save_post_meta( 'meta-robots-noindex', $robot_value['index'], $post_id );
$this->maybe_save_post_meta( 'meta-robots-nofollow', $robot_value['follow'], $post_id );
}
/**
* Imports the taxonomy metas from wpSEO.
*
* @return void
*/
private function import_taxonomy_metas() {
$terms = get_terms(
[
'taxonomy' => get_taxonomies(),
'hide_empty' => false,
],
);
$tax_meta = get_option( 'wpseo_taxonomy_meta' );
foreach ( $terms as $term ) {
$this->import_taxonomy_description( $tax_meta, $term->taxonomy, $term->term_id );
$this->import_taxonomy_robots( $tax_meta, $term->taxonomy, $term->term_id );
}
update_option( 'wpseo_taxonomy_meta', $tax_meta );
}
/**
* Imports the meta description to Yoast SEO.
*
* @param array $tax_meta The array with the current metadata.
* @param string $taxonomy String with the name of the taxonomy.
* @param string $term_id The ID of the current term.
*
* @return void
*/
private function import_taxonomy_description( &$tax_meta, $taxonomy, $term_id ) {
$description = get_option( 'wpseo_' . $taxonomy . '_' . $term_id, false );
if ( $description !== false ) {
// Import description.
$tax_meta[ $taxonomy ][ $term_id ]['wpseo_desc'] = $description;
}
}
/**
* Imports the robot value to Yoast SEO.
*
* @param array $tax_meta The array with the current metadata.
* @param string $taxonomy String with the name of the taxonomy.
* @param string $term_id The ID of the current term.
*
* @return void
*/
private function import_taxonomy_robots( &$tax_meta, $taxonomy, $term_id ) {
$wpseo_robots = get_option( 'wpseo_' . $taxonomy . '_' . $term_id . '_robots', false );
if ( $wpseo_robots === false ) {
return;
}
// The value 1, 2 and 6 are the index values in wpSEO.
$new_robot_value = 'noindex';
if ( in_array( (int) $wpseo_robots, [ 1, 2, 6 ], true ) ) {
$new_robot_value = 'index';
}
$tax_meta[ $taxonomy ][ $term_id ]['wpseo_noindex'] = $new_robot_value;
}
/**
* Deletes the wpSEO taxonomy meta data.
*
* @param string $taxonomy String with the name of the taxonomy.
* @param string $term_id The ID of the current term.
*
* @return void
*/
private function delete_taxonomy_metas( $taxonomy, $term_id ) {
delete_option( 'wpseo_' . $taxonomy . '_' . $term_id );
delete_option( 'wpseo_' . $taxonomy . '_' . $term_id . '_robots' );
}
/**
* Gets the robot config by given wpSEO robots value.
*
* @param string $wpseo_robots The value in wpSEO that needs to be converted to the Yoast format.
*
* @return string The correct robot value.
*/
private function get_robot_value( $wpseo_robots ) {
if ( array_key_exists( $wpseo_robots, $this->robot_values ) ) {
return $this->robot_values[ $wpseo_robots ];
}
return $this->robot_values[1];
}
/**
* Deletes wpSEO postmeta from the database.
*
* @return bool Cleanup status.
*/
private function cleanup_post_meta() {
global $wpdb;
// If we get to replace the data, let's do some proper cleanup.
return $wpdb->query( "DELETE FROM {$wpdb->postmeta} WHERE meta_key LIKE '_wpseo_edit_%'" );
}
/**
* Cleans up the wpSEO term meta.
*
* @return void
*/
private function cleanup_term_meta() {
$terms = get_terms(
[
'taxonomy' => get_taxonomies(),
'hide_empty' => false,
],
);
foreach ( $terms as $term ) {
$this->delete_taxonomy_metas( $term->taxonomy, $term->term_id );
}
}
}